﻿using System;
using Lidgren.Network;
using NetBrick.Common;
using NetBrick.Common.Packets;

namespace NetBrick.Server.Handler
{
    public class EstablishEncryptionPacketHandler : PacketHandler
    {
        public EstablishEncryptionPacketHandler(Server server) : base(server)
        {
        }

        public override void Process(Object packetData, BasePeer sender)
        {
            var establishEncryptionPacket = new EstablishEncryptionPacket.Response(sender.EstablishEncryption());
            Server.SendPacket(NetBrickPacketCode.EstablishEncryptionResponse, establishEncryptionPacket, sender,
                NetDeliveryMethod.ReliableOrdered);
            Log.Info("Established encryption for a client.");
        }
    }
}